//
//  ForgetServer.m
//  Base_App
//
//  Created by Yutian Duan on 2019/6/25.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "ForgetServer.h"

@implementation ForgetServer

///! 忘记密码
- (void)forgetPassword:(NSString *)phoneStr code:(NSString *)code newPassword:(NSString *)password finished:(BaseServer)finished failed:(BaseServerError)failed {
  
  NSDictionary *params = @{
                           @"phone":phoneStr,
                           @"phonecode":code,
                           @"password":password
                           };
  
  
  [self startHTTPWithMethod:YFRequestMethodPOST params:params key:@"login/doAppforgetpwd" finished:^(Result *returnValue) {
    if (returnValue.status == 200) {
      ///! 清除旧密码
      finished(YES);
    } else {
      finished(NO);
    }
  } failed:^(id errorCode) {
    failed(errorCode);
  }];

  
}

///! 发验证码
- (void)sendmassgeCodeWithPhone:(NSString *)phone finished:(BaseServer)finish failed:(BaseServerError)failed {
  
  NSDictionary *parmas = @{
                           @"phone":phone
                           };
  
  [self startHTTPWithMethod:YFRequestMethodPOST params:parmas key:@"sms/getuserforgetcode" finished:^(Result *returnValue) {
    if (returnValue.status == 200) {
      finish(YES);
    } else {
      [Tools showErrorWithStatus:returnValue.msg];
      finish(NO);
    }
    
  } failed:^(id errorCode) {
    failed(errorCode);
  }];
  
  
}


@end
